package com.lire.shop.dao;

import com.lire.shop.entity.Wallet;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Repository
@Transactional
public interface WalletRepository extends JpaRepository<Wallet, Long> {

    @Modifying
    @Query(value = "update shop_wallet w set w.balances = :balances where w.wid = :wid")
    int updateBalancesByWid(@Param("balances") BigDecimal balances, @Param("wid") Long wid);
}
